package com.block.common.security.service.impl;


import com.block.common.security.service.AppEncryptMannerService;
import com.block.common.util.AESOperator;
import com.block.db.entity.AppEncrypt;

public class AESIVEncryptManager implements AppEncryptMannerService {
//	private static final Logger log = Logger.getLogger(AESEncryptManner.class);
	
	//加密
	@Override
	public String encode(AppEncrypt appEncrypt, String tranData, String cipherKey) {
		
			try {
				return AESOperator.encrypt(tranData, cipherKey);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				String data = "异常信息：" + e.getMessage() + "【tranDate】" + tranData + "【cipherKey】" + cipherKey;
//				log.error("【AES解密时urldecode出异常】" + data);
//				MailUtil.sendExceptionMail("【AES加密时urldecode出异常】", data + "\n" + ExceptionUtil.getExceptionStackTrace(e, "【AES解密 】"));
				e.printStackTrace();
				return null;
			}
		
	}

	//解密
	@Override
	public String decode(AppEncrypt appEncrypt, String tranData, String cipherKey) {
		try {
			return AESOperator.decrypt(tranData, cipherKey);
		} catch (Exception e) {
			String data = "异常信息：" + e.getMessage() + "【tranDate】" + tranData + "【cipherKey】" + cipherKey;
//			log.error("【AES解密时urldecode出异常】" + data);
//			MailUtil.sendExceptionMail("【AES解密时urldecode出异常】", data + "\n" + ExceptionUtil.getExceptionStackTrace(e, "【AES解密 】"));
			e.printStackTrace();
			return null;
		}
	}
}
